package org.jeecg.modules.dock.entity.ems.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.dock.entity.BaseResponseV0;
import org.jeecg.modules.dock.entity.mds.MdsBaseResponseVO;

import java.io.Serializable;


/**
 * mds响应通用实体
 *
 * @author zhoutong
 */
@ApiModel(value = "mds响应通用实体", description = "mds响应通用实体")
@Data
@ToString(callSuper = true)
public class EmsBaseResponseVO<T> extends BaseResponseV0 implements Serializable {

    @ApiModelProperty("返回代码（定义的错误码)没有错误时返回0")
    private Integer errcode;

    @ApiModelProperty("传输数据")
    private T data;

    public EmsBaseResponseVO() {

    }

    public static EmsBaseResponseVO error() {
        EmsBaseResponseVO r = new EmsBaseResponseVO();
        r.setTarget(ERROR);
        r.setErrcode(400);
        return r;
    }
    public static EmsBaseResponseVO error(String msg) {
        EmsBaseResponseVO r = new EmsBaseResponseVO();
        r.setTarget(ERROR);
        r.setErrcode(400);
        r.setMsg(msg);
        return r;
    }
    public static <T> EmsBaseResponseVO<T> ok(T data) {
        EmsBaseResponseVO<T> r = new EmsBaseResponseVO<T>();
        r.setTarget(SUCCESS);
        r.setErrcode(CommonConstant.STATUS_NORMAL);
        r.setData(data);
        r.setMsg("请求成功！");
        return r;
    }

    public static <T> EmsBaseResponseVO<T> ok() {
        EmsBaseResponseVO<T> r = new EmsBaseResponseVO<T>();
        r.setTarget(SUCCESS);
        r.setErrcode(CommonConstant.STATUS_NORMAL);
        r.setMsg("请求成功！");
        return r;
    }

}
